package com.gztms.blogmgnt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gztms.blogmgnt.mapper.BlogReviewMapper;
import com.gztms.blogmgnt.pojo.Blog;
import com.gztms.blogmgnt.pojo.BlogReview;
import com.gztms.blogmgnt.pojo.BlogStatus;
import com.gztms.blogmgnt.service.BlogReviewService;
import com.gztms.blogmgnt.service.BlogService;
import com.gztms.enums.AppCodeEnum;
import com.gztms.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * (BlogReview)表服务实现类
 *
 * @author makejava
 * @since 2023-05-09 13:20:28
 */
@Service("blogReviewService")
@Slf4j
public class BlogReviewServiceImpl extends ServiceImpl<BlogReviewMapper, BlogReview> implements BlogReviewService {

    @Autowired
    private BlogService blogService;
    @Override
    public ResultUtil addBlogReview(BlogReview blogReview) {
        log.info("blogReview:  {}", blogReview);
        Blog blog = new Blog();
        blog.setStatus(blogReview.getStatus());
        blog.setBid(blogReview.getBlogId());
        blogService.updateById(blog);
        boolean save = save(blogReview);
        if (save) {
//            Blog blog = new Blog();
//            blog.setStatus(blogReview.getStatus());
//            blog.setBid(blogReview.getBlogId());
//            blogService.updateById(blog);
            return new ResultUtil(AppCodeEnum.SUCCESS.getCode(),"操作成功");
        }
        return ResultUtil.errorResult(AppCodeEnum.SYSTEM_ERROR);
    }
}

